
/**
 * @Project : Clion_ProgrammingExercises
 * @File : 3
 * @Author : WangRuoyu 
 * @Date : 2023/5/12 16:47
 */

#include "iostream"
#include "cstring"
#include "algorithm"

using namespace std;

int const N = 110;
int m, n, q;
char g[N][N];
bool st[N][N];
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

void dfs(int x, int y, char c) {
    g[x][y] = c;
    st[x][y] = true;
    for (int i = 0; i < 4; ++i) {
        int a = x + dx[i];
        int b = y + dy[i];
        if (a >= 0 && a < m && b >= 0 && b < n && !st[a][b]) {
            if (g[a][b] != '-' && g[a][b] != '|' && g[a][b] != '+') {
                dfs(a, b, c);
            }
        }
    }
}

int main() {
    cin >> m >> n >> q;
    for (int i = 0; i < m; ++i) {
        for (int j = 0; j < n; ++j) {
            g[i][j] = '.';
        }
    }

    while (q--) {
        int op;
        cin >> op;
        if (op == 0) {
            int x1, y1, x2, y2;
            cin >> x1 >> y1 >> x2 >> y2;
            if (x1 > x2) swap(x1, x2);
            if (y1 > y2) swap(y1, y2);
            char p1 = '-', p2 = '|';
            if (x1 == x2) swap(p1, p2);
            for (int i = x1; i <= x2; ++i) {
                for (int j = y1; j <= y2; ++j) {
                    if (g[i][j] == p2 || g[i][j] == '+') g[i][j] = '+';
                    else g[i][j] = p1;
                }
            }
        } else {
            int x, y;
            char c;
            cin >> x >> y >> c;
            for (int i = 0; i < m; ++i) {
                for (int j = 0; j < n; ++j) {
                    st[i][j] = false;
                }
            }
            dfs(x, y, c);
        }
    }

    for (int j = n - 1; j >= 0; --j) {
        for (int i = 0; i < m; ++i) {
            cout << g[i][j];
        }
        cout << endl;
    }
    return 0;
}